import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in) ;
		Map<String,Integer> map = new HashMap<String,Integer>() ;
		while(sc.hasNextLine()){
			String line = sc.nextLine() ;
			if("!!!!!".equals(line))
				break ;
			Scanner lineScanner = new Scanner(line) ;
			while(lineScanner.hasNext()){
				String str = lineScanner.next() ;
				if(map.containsKey(str))
					map.put(str, map.get(str) + 1) ;
				else
					map.put(str, 1) ;
			}
			lineScanner.close();
		}
		sc.close() ;
		System.out.println(map.size());
		List<Entry<String,Integer>> list = new ArrayList<Entry<String,Integer>>(map.entrySet()) ;		
		Collections.sort(list,new Comparator<Entry<String,Integer>>(){
			public int compare(Entry<String, Integer> o1, Entry<String, Integer> o2) {
					if(o1.getValue() == o2.getValue())
						return o1.getKey().compareTo(o2.getKey()) ;
					return o2.getValue() - o1.getValue() ;
			}
		}) ;
		if(list.size() <= 10)
			  for(int i = 0 ; i < list.size() ; i++)
			    System.out.println(list.get(i)) ;
			else{
			  for(int i = 0 ; i < 10 ; i++)
			    System.out.println(list.get(i)) ;
			}
	}
}